Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
    ''' <summary>
    ''' Controller class for aspnet_Users
    ''' </summary>
		<System.ComponentModel.DataObject()> Public Partial Class AspnetUsersController
    
        ' Preload our schema..
        Dim thisSchemaLoad As AspnetUsers = New AspnetUsers()
        Private strUserName As String = String.Empty
        Protected ReadOnly Property UserName() As String
            Get
				If strUserName.Length = 0 Then
		        
    				If Not System.Web.HttpContext.Current Is Nothing Then
						strUserName = System.Web.HttpContext.Current.User.Identity.Name
					Else
		        		strUserName = System.Threading.Thread.CurrentPrincipal.Identity.Name
					End If
					Return strUserName
				End If
				Return strUserName
			End Get
        End Property
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchAll() As AspnetUsersCollection
        
            Dim coll As AspnetUsersCollection = New AspnetUsersCollection()
            Dim qry As Query = New Query(AspnetUsers.Schema)
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
            
        End Function
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByID(ByVal UserId As Object) As AspnetUsersCollection 
        
            Dim coll As AspnetUsersCollection = New AspnetUsersCollection().Where("UserId", UserId).Load()
            Return coll
        
        End Function
        
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByQuery(ByVal qry As SubSonic.Query) As AspnetUsersCollection 
        
            Dim coll As AspnetUsersCollection = New AspnetUsersCollection()
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, True)> Public Function Delete(ByVal UserId As Object) as Boolean
        
            Return (AspnetUsers.Delete(UserId) = 1)
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, False)> Public Function Destroy(ByVal UserId As Object) as Boolean
        
            Return (AspnetUsers.Destroy(UserId) = 1)
        
        End Function
        
    	
	    ''' <summary>
	    ''' Inserts a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Insert, True)> Public Sub Insert(ByVal ApplicationId As Guid,ByVal UserId As Guid,ByVal UserName As String,ByVal LoweredUserName As String,ByVal MobileAlias As String,ByVal IsAnonymous As Boolean,ByVal LastActivityDate As DateTime)
	   
		    Dim item As AspnetUsers = New AspnetUsers()
		    
            item.ApplicationId = ApplicationId
            
            item.UserId = UserId
            
            item.UserName = UserName
            
            item.LoweredUserName = LoweredUserName
            
            item.MobileAlias = MobileAlias
            
            item.IsAnonymous = IsAnonymous
            
            item.LastActivityDate = LastActivityDate
            
	    
		    item.Save(UserName)
	   
	   End Sub
    	
	    ''' <summary>
	    ''' Updates a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Update, True)> Public Sub Update(ByVal ApplicationId As Guid,ByVal UserId As Guid,ByVal UserName As String,ByVal LoweredUserName As String,ByVal MobileAlias As String,ByVal IsAnonymous As Boolean,ByVal LastActivityDate As DateTime)
	    
		    Dim item As AspnetUsers = New AspnetUsers()
		    
				item.ApplicationId = ApplicationId
				
				item.UserId = UserId
				
				item.UserName = UserName
				
				item.LoweredUserName = LoweredUserName
				
				item.MobileAlias = MobileAlias
				
				item.IsAnonymous = IsAnonymous
				
				item.LastActivityDate = LastActivityDate
				
		    item.MarkOld()
		    item.Save(UserName)
	    
	    End Sub
    End Class
End Namespace
